<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    class Super{
        constructor(){
            this.setElement()
            this. setColor()
        }
        //创建元素
        setElement(){
            this.dom = document.createElement("div")
        }
        //创建随机数
        randomName(min,max){
            return Math.floor(Math.random()*(max-min)+min)
        }
        //添加随机颜色
        setColor(){
            this.dom.style.backgroundColor = `rgba(${this.randomName(0,255)},${this.randomName(0,255)},${Math.random()})`      
        }
    }
</script>